
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ReadText {
	static void readText(String filename, String inkey) throws IOException{
	     

	String key = "==="+inkey+"===";
	
	try {       
		BufferedReader in = new BufferedReader(new FileReader(filename));
	Boolean flag = false;
	String str;     
	while ((str = in.readLine()) != null) {    
		
		 
		if ((str.startsWith("=")) && (str.contains(key))) {
			
			if (flag == false) {flag = true; }
		}
		
		if ((str.startsWith("=")) && (!(str.contains(key)))) {
			
			if (flag == true) {flag = false; }
		}
		
		
		if (flag == true){
			System.out.println(str);
		}	
		
	}  
	in.close();    
	} catch (IOException e) {  
		
		System.out.println("Cant open file");
	}       
	
	}   
	public static void main(String[] args) throws IOException {        
	ReadText.readText("/home/user/Documents/labs/Find/text.txt","rightkey");       
	}
	

}
